home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / structmember.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  1.9 KB  |  71 lines

  1. #ifndef Py_STRUCTMEMBER_H
  2. #define Py_STRUCTMEMBER_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Interface to map C struct members to Python object attributes */
  8.  
  9. #ifdef HAVE_STDDEF_H
  10. #include <stddef.h> /* For offsetof */
  11. #endif
  12.  
  13. /* The offsetof() macro calculates the offset of a structure member
  14.    in its structure.  Unfortunately this cannot be written down
  15.    portably, hence it is provided by a Standard C header file.
  16.    For pre-Standard C compilers, here is a version that usually works
  17.    (but watch out!): */
  18.  
  19. #ifndef offsetof
  20. #define offsetof(type, member) ( (int) & ((type*)0) -> member )
  21. #endif
  22.  
  23. /* An array of memberlist structures defines the name, type and offset
  24.    of selected members of a C structure.  These can be read by
  25.    PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
  26.    is set).  The array must be terminated with an entry whose name
  27.    pointer is NULL. */
  28.  
  29. struct memberlist {
  30.     char *name;
  31.     int type;
  32.     int offset;
  33.     int readonly;
  34. };
  35.  
  36. /* Types */
  37. #define T_SHORT        0
  38. #define T_INT        1
  39. #define T_LONG        2
  40. #define T_FLOAT        3
  41. #define T_DOUBLE    4
  42. #define T_STRING    5
  43. #define T_OBJECT    6
  44. /* XXX the ordering here is weird for binary compatibility */
  45. #define T_CHAR        7    /* 1-character string */
  46. #define T_BYTE        8    /* 8-bit signed int */
  47. /* unsigned variants: */
  48. #define T_UBYTE        9
  49. #define T_USHORT    10
  50. #define T_UINT        11
  51. #define T_ULONG        12
  52.  
  53. /* Added by Jack: strings contained in the structure */
  54. #define T_STRING_INPLACE    13
  55. #ifdef macintosh
  56. #define T_PSTRING    14    /* macintosh pascal-style counted string */
  57. #define T_PSTRING_INPLACE    15
  58. #endif /* macintosh */
  59.  
  60. /* Readonly flag */
  61. #define READONLY    1
  62. #define RO        READONLY        /* Shorthand */
  63.  
  64. DL_IMPORT(PyObject *) PyMember_Get Py_PROTO((char *, struct memberlist *, char *));
  65. DL_IMPORT(int) PyMember_Set Py_PROTO((char *, struct memberlist *, char *, PyObject *));
  66.  
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif /* !Py_STRUCTMEMBER_H */
  71.